<template>
  <el-dialog
    width="500px"
    title="退瓶消单确认"
    :visible.sync="visible"
    append-to-body
    @close="onClose"
  >
    <el-form ref="form" :model="form">
      <el-form-item prop="returnDepBottleType">
        <el-radio-group v-model="form.returnDepBottleType">
          <el-radio :label="2">退瓶消单客户退空瓶</el-radio>
          <el-radio :label="1">退瓶消单客户不退空瓶</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <p class="tip">注：客户退空瓶，需要扫瓶入库</p>
    <div slot="footer" class="dialog-footer">
      <el-button @click="onClose">取 消</el-button>
      <el-button type="primary" @click="onConfirm">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  export default {
    name: 'turnOrderConfirm',
    data() {
      return {
        visible: false,
        form: {
          returnDepBottleType: 2
        }
      }
    },
    methods: {
      async open() {
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
        })
      },
      onClose() {
        this.form = {
          returnDepBottleType: 2
        }
        this.visible = false
      },
      onConfirm() {
        this.$refs.form.validate(async(valid) => {
          if (!valid) return
          this.resolve(this.form)
          this.visible = false
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
.tip {
  color: red;
}
</style>
